<template>
  <v-app>
  <v-navigation-drawer v-model="drawer" :clipped="$vuetify.breakpoint.lgAndUp" app width="280">
    
      <v-divider></v-divider>
      <v-list dense>
        <v-list-group v-for="(item, key) in items" :key="key" v-model="item.active" :append-icon="item.appendIcon" @click="itemClick(item, key)">
          <template v-slot:activator>
            <v-list-item-icon>
              <v-icon v-text="item.icon"></v-icon>
            </v-list-item-icon>
            <v-list-item-content>
              <v-list-item-title v-text="item.title"></v-list-item-title>
            </v-list-item-content>
          </template>
          <v-list-item-group v-if="item.children" color="primary" v-model="subItemActive">
            <v-list-item v-for="(subItem, k) in item.children" :key="k" @click="subItemClick(subItem, k)">
              <v-list-item-icon></v-list-item-icon>

              <v-list-item-content>
                <v-list-item-title v-text="subItem.title"></v-list-item-title>
              </v-list-item-content>
            </v-list-item>
          </v-list-item-group>
        </v-list-group>
      </v-list>
    </v-navigation-drawer>
  </v-app>
</template>

<script>
export default {
  props: {
    value: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    value(val) {
      this.drawer = val;
    },
  },
  close() {
    this.$emit("input", false);
  },
  data() {
    return {  
      drawer: true,
      subItemActive:0
    };
  },
   computed: {
    items: function () {
      return [
        {
          icon: 'mdi-account',
          title: this.$vuetify.lang.t('$vuetify.sidebar.titleIntroduction.value'),
          path: 'home',
          appendIcon: null,
          active: true
        },
        {
          icon: 'mdi-account-multiple',
          title: this.$vuetify.lang.t('$vuetify.sidebar.title1.value'),
          children: [
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title1.children.title1.value'),path:'home'},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title1.children.title2.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title1.children.title3.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title1.children.title4.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title1.children.title5.value')}
          ],
          appendIcon: 'mdi-chevron-down'
        },
        {
          icon: 'mdi-star',
          title: this.$vuetify.lang.t('$vuetify.sidebar.title2.value'),
          children: [
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title1.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title2.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title3.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title4.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title5.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title6.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title7.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title2.children.title8.value')}
          ],
          appendIcon: 'mdi-chevron-down'
        },
        {
          icon: 'mdi-check-circle',
          title: this.$vuetify.lang.t('$vuetify.sidebar.title3.value'),
          children: [
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title3.children.title1.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title3.children.title2.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title3.children.title3.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title3.children.title4.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title3.children.title5.value')}
          ],
          appendIcon: 'mdi-chevron-down'
        },
        {
          icon: 'mdi-upload',
          title: this.$vuetify.lang.t('$vuetify.sidebar.title4.value'),
          children: [
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title4.children.title1.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title4.children.title2.value')},
          ],
          appendIcon: 'mdi-chevron-down'
        },
        {
          icon: 'mdi-cloud-upload',
          title: this.$vuetify.lang.t('$vuetify.sidebar.title5.value'),
          children: [
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title5.children.title1.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title5.children.title2.value')},
            { title: this.$vuetify.lang.t('$vuetify.sidebar.title5.children.title3.value')},
           
          ],
          appendIcon: 'mdi-chevron-down'
        },
      
      ]
    }
  },
  methods: {
      itemClick (item, key) {
      this.subItemActive = null
      sessionStorage.setItem('itemActive', key)
      console.dir(item)
      if (!item.children) {
        this.$router.push(item.path).catch(err => { })
      }
    },
     subItemClick (item, key) {
      sessionStorage.setItem('subItemActive', key)
      this.$router.push(item.path).catch(err => { })
    },
  },
  
};
</script>

<style>
</style>